<?php
/**
 * Classe FORM da tabela OBITO
 * 
 * @author			Mário R. Castro
 * @copyright		Voitech Sistema
 * @package			SEMAS
 * @subpackage		semas.application.controller
 * @version			1.0
*/
class App_Form_Obito extends Voitech_Form
{
	public function __construct($options=array())
	{
		parent::__construct($options);
		
		$this->setAttribs(array('name'=>'frmCadastroObito', 'id'=>'frmCadastroObito', 'class'=>'form last-child'));
		
		// add id element
        $this->addElement('hidden', 'co_obito');
        
        // remove id's decorators
        $this->getElement('co_obito')
            ->removeDecorator('DtDdWrapper')
            ->removeDecorator('HtmlTag')
            ->removeDecorator('Label');
		
		$noObito 	= new Zend_Form_Element_Text( 'nu_obito' );
		$noObito->setLabel( 'Cadastro de Óbito Num.:' )
				 ->setAttribs( array('size'=>'40','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'30' ) ) )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( true );
		$this->addElement( $noObito );				
		// add id element
        $this->addElement('hidden', 'co_pessoa');
        
        // remove id's decorators
        $this->getElement('co_pessoa')
            ->removeDecorator('DtDdWrapper')
            ->removeDecorator('HtmlTag')
            ->removeDecorator('Label');
		
		$noPessoa 	= new Zend_Form_Element_Text( 'no_pessoa' );
		$noPessoa->setLabel( 'Nome do Falecido:' )
				 ->setAttribs( array('size'=>'70','class'=> 'first-child last-child',"readonly" => "readonly") )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
		         ->setDecorators( $this->_decoratorLeft )
				 ->setRequired( true );
		$this->addElement( $noPessoa );				

        $buttonCdstPessoa = new Zend_Form_Element_Button('Pessoa');
		$buttonCdstPessoa->setAttribs( array('class'=> 'first-child last-child', 'id' => 'bntAddPessoa' ) )
		           ->setDecorators( $this->_decoratorDefault );
		//$buttonCdstFornecedor->removeDecorator( 'label' );
        $this->addElement( $buttonCdstPessoa ); 		
		
        $obReligiaoRepositorio = new App_Model_ParamReligiaoRepository();
        $selectBoxSexo = new Zend_Form_Element_Select( 'co_religiao' );
            $selectBoxSexo->setLabel('Religião:');
            $selectBoxSexo->setAttribs( array('class'=> 'last-child' ) );
            $selectBoxSexo->setDecorators( $this->_decoratorDefault );
            $selectBoxSexo->addMultiOptions( Voitech_Util::converteModeloArrayCombo($obReligiaoRepositorio->listarTodos(array('st_ativo'=>'S'))
                                            , 'CoReligiao', 'NoReligiao', true) );
            $selectBoxSexo->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $selectBoxSexo );        
									 
		$noPai 	= new Zend_Form_Element_Text( 'no_pai' );
		$noPai->setLabel( 'Nome do Pai:' )
				 ->setAttribs( array('size'=>'70','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( true );
		$this->addElement( $noPai );        

		$noMae 	= new Zend_Form_Element_Text( 'no_mae' );
		$noMae->setLabel( 'Nome da Mãe:' )
				 ->setAttribs( array('size'=>'70','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( true );
		$this->addElement( $noMae ); 		

		$this->addDisplayGroup(array('co_obito','nu_obito','co_pessoa','no_pessoa','Pessoa', 'no_pai', 'no_mae','co_religiao')
									 ,'Cadastro',array('legend' => 'Dados Pessoais do Falecido', 'class'=>'grey-bg first-child last-child fieldset-with-legend fieldset-with-legend-first-child'));        
       		
		
		$noDeclaracao 	= new Zend_Form_Element_Text( 'no_declaracao' );
		$noDeclaracao->setLabel( 'Declaração:' )
				 ->setAttribs( array('size'=>'50','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
		         ->setDecorators( $this->_decoratorLeft )
				 ->setRequired( false );
		$this->addElement( $noDeclaracao ); 		

		$noIdade 	= new Zend_Form_Element_Text( 'nu_idade' );
		$noIdade->setLabel( 'Idade:' )
				 ->setAttribs( array('size'=>'15','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_Int() )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( true );
		$this->addElement( $noIdade );		

		$noForm 	= new Zend_Form_Element_Text( 'dt_obito' );
		$noForm->setLabel( 'Data do Óbito:' )
				 ->setAttribs( array('size'=>'15','class'=> 'first-child last-child campo_data') )
		         ->addFilter( new Zend_Filter_StringTrim() )
		         ->setDecorators( $this->_decoratorLeft )
				 ->setRequired( true );
		$this->addElement( $noForm ); 		

		$noForm 	= new Zend_Form_Element_Text( 'nu_hora' );
		$noForm->setLabel( 'Hora do Óbito:' )
				 ->setAttribs( array('size'=>'15','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_Int() )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( true );
		$this->addElement( $noForm );			

        $obCartorioRepositorio = new App_Model_CartorioRepository();
        $noForm = new Zend_Form_Element_Select( 'co_cartorio' );
            $noForm->setLabel('Cartório:');
            $noForm->setAttribs( array('class'=> 'last-child' ) );
            $noForm->setDecorators( $this->_decoratorLeft );
            $noForm->addMultiOptions( Voitech_Util::converteModeloArrayCombo($obCartorioRepositorio->listarTodos(array('st_ativo'=>'S'))
                                            , 'CoCartorio', 'NoCartorio', true) );
            $noForm->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $noForm );		

        $buttonCdst = new Zend_Form_Element_Button('Cartorio');
		$buttonCdst->setAttribs( array('class'=> 'first-child last-child', 'id' => 'bntAddCartorio' ) )
		           ->setDecorators( $this->_decoratorLeft );
		//$buttonCdstFornecedor->removeDecorator( 'label' );
        $this->addElement( $buttonCdst ); 
                

		$noForm 	= new Zend_Form_Element_Text( 'nu_certidao' );
		$noForm->setLabel( 'Certidão:' )
				 ->setAttribs( array('size'=>'25','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_Int() )
		         ->setDecorators( $this->_decoratorDefault );
		$this->addElement( $noForm );

		
		$this->addDisplayGroup(array( 'no_declaracao', 'nu_idade','dt_obito','nu_hora','co_cartorio','Cartorio', 'nu_certidao'	)
									 ,'Cadastro2',array('legend' => 'Dados do Falecimento', 'class'=>'grey-bg first-child last-child fieldset-with-legend fieldset-with-legend-first-child'));

									 
        $this->addElement('hidden', 'co_unidade_saude');
        
        // remove id's decorators
        $this->getElement('co_unidade_saude')
            ->removeDecorator('DtDdWrapper')
            ->removeDecorator('HtmlTag')
            ->removeDecorator('Label');
		
		$noPessoa 	= new Zend_Form_Element_Text( 'no_unidade_saude' );
		$noPessoa->setLabel( 'Hospital/Local onde se encontra o corpo:' )
				 ->setAttribs( array('size'=>'70','class'=> 'first-child last-child',"readonly" => "readonly") )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'1', 'max'=>'255' ) ) )
		         ->setDecorators( $this->_decoratorLeft )
				 ->setRequired( true );
		$this->addElement( $noPessoa );	
        									 
        $buttonCdst = new Zend_Form_Element_Button('Local');
		$buttonCdst->setAttribs( array('class'=> 'first-child last-child', 'id' => 'bntAddUnidadeSaude' ) )
		           ->setDecorators( $this->_decoratorDefault );
		//$buttonCdstFornecedor->removeDecorator( 'label' );
        $this->addElement( $buttonCdst );  
        									 
		$noForm 	= new Zend_Form_Element_Text( 'ds_causa_obito' );
		$noForm->setLabel( 'Causa da Morte:' )
				 ->setAttribs( array('size'=>'70','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( false );
		$this->addElement( $noForm );		


/*  Inicio Add Elementos do Cadastro de Medico       */
        $this->addElement('hidden', 'co_medico');
        $this->getElement('co_medico')
            ->removeDecorator('DtDdWrapper')
            ->removeDecorator('HtmlTag')
            ->removeDecorator('Label');
		
		$noPessoa 	= new Zend_Form_Element_Text( 'no_medico' );
		$noPessoa->setLabel( 'Nome do Médico:' )
				 ->setAttribs( array('size'=>'55','class'=> 'first-child last-child',"readonly" => "readonly") )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
				 ->addFilter( new Zend_Filter_StringTrim() )
		         ->setDecorators( $this->_decoratorLeft )
				 ->setRequired( true );
		$this->addElement( $noPessoa );            
            
        $buttonCdstPessoa = new Zend_Form_Element_Button('Medico');
		$buttonCdstPessoa->setAttribs( array('class'=> 'first-child last-child', 'id' => 'bntAddMedico' ) )
		           ->setDecorators( $this->_decoratorDefault );
		//$buttonCdstFornecedor->removeDecorator( 'label' );
        $this->addElement( $buttonCdstPessoa );              
/*  Fim Add Elementos do Cadastro de Medico        */  		

		$noForm 	= new Zend_Form_Element_Text( 'nu_crm' );
		$noForm->setLabel( 'CRM:' )
				 ->setAttribs( array('size'=>'15','class'=> 'first-child last-child',"readonly" => "readonly") )
		         ->addFilter( new Zend_Filter_StringTrim() )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( false );
		$this->addElement( $noForm );	

/*  Inicio Add Elementos do Cadastro de Funeraria       */
        $this->addElement('hidden', 'co_funeraria');
        $this->getElement('co_funeraria')
            ->removeDecorator('DtDdWrapper')
            ->removeDecorator('HtmlTag')
            ->removeDecorator('Label');
		
		$noPessoa 	= new Zend_Form_Element_Text( 'no_funeraria' );
		$noPessoa->setLabel( 'Nome da Funerária:' )
				 ->setAttribs( array('size'=>'70','class'=> 'first-child last-child',"readonly" => "readonly") )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
				 ->addFilter( new Zend_Filter_StringTrim() )
		         ->setDecorators( $this->_decoratorLeft )
				 ->setRequired( false );
		$this->addElement( $noPessoa );            
            
        $buttonCdstPessoa = new Zend_Form_Element_Button('Funerária');
		$buttonCdstPessoa->setAttribs( array('class'=> 'first-child last-child', 'id' => 'bntAddFuneraria' ) )
		           ->setDecorators( $this->_decoratorDefault );
		//$buttonCdstFornecedor->removeDecorator( 'label' );
        $this->addElement( $buttonCdstPessoa );              
/*  Fim Add Elementos do Cadastro de Medico        */  	

/*  Inicio Add Elementos do Cadastro de Cemiterio       */
        $this->addElement('hidden', 'co_cemiterio');
        $this->getElement('co_cemiterio')
            ->removeDecorator('DtDdWrapper')
            ->removeDecorator('HtmlTag')
            ->removeDecorator('Label');
		
		$noPessoa 	= new Zend_Form_Element_Text( 'no_cemiterio' );
		$noPessoa->setLabel( 'Nome do Cemitério:' )
				 ->setAttribs( array('size'=>'70','class'=> 'first-child last-child',"readonly" => "readonly") )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
				 ->addFilter( new Zend_Filter_StringTrim() )
		         ->setDecorators( $this->_decoratorLeft )
				 ->setRequired( false );
		$this->addElement( $noPessoa );            
            
        $buttonCdstPessoa = new Zend_Form_Element_Button('Cemitério');
		$buttonCdstPessoa->setAttribs( array('class'=> 'first-child last-child', 'id' => 'bntAddCemiterio' ) )
		           ->setDecorators( $this->_decoratorDefault );
		//$buttonCdstFornecedor->removeDecorator( 'label' );
        $this->addElement( $buttonCdstPessoa );              
/*  Fim Add Elementos do Cadastro de Cemiterio        */        

        $noForm = new Zend_Form_Element_Select( 'st_plano_funerario' );
            $noForm->setLabel('Plano Funerário:');
            $noForm->setAttribs( array('class'=> 'last-child' ) );
            $noForm->setDecorators( $this->_decoratorDefault );
            $noForm->addMultiOptions( array('N'=>'Não','S'=>'Sim'));
            $noForm->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $noForm );        
        
        $obClasseRepositorio = new App_Model_ParamClasseRepository();
        $noForm = new Zend_Form_Element_Select( 'co_classe' );
            $noForm->setLabel('Classe:');
            $noForm->setAttribs( array('class'=> 'last-child' ) );
            $noForm->setDecorators( $this->_decoratorLeft );
            $noForm->addMultiOptions( Voitech_Util::converteModeloArrayCombo($obClasseRepositorio->listarTodos(array('st_ativo'=>'S'))
                                            , 'CoClasse', 'NoClasse', true));
            $noForm->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $noForm );   

		$noForm 	= new Zend_Form_Element_Text( 'ds_velorio' );
		$noForm->setLabel( 'Velório:' )
				 ->setAttribs( array('size'=>'70','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
		         ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'200' ) ) )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( false );
		$this->addElement( $noForm );	

		
		$this->addDisplayGroup(array( 'co_unidade_saude','no_unidade_saude','Local','ds_causa_obito','co_medico','no_medico','Medico','nu_crm','co_funeraria','no_funeraria','Funerária'
										,'co_cemiterio','no_cemiterio','Cemitério','co_classe','st_plano_funerario','ds_velorio'	)
									 ,'Cadastro3',array('legend' => 'Dados de Local e Causa', 'class'=>'grey-bg first-child last-child fieldset-with-legend fieldset-with-legend-first-child'));
		

									 
		$noForm 	= new Zend_Form_Element_Text( 'no_declarante' );
		$noForm->setLabel( 'Declarante:' )
				 ->setAttribs( array('size'=>'55','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
		         ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'100' ) ) )
		         ->setDecorators( $this->_decoratorLeft )
				 ->setRequired( false );
		$this->addElement( $noForm );	

		$noForm 	= new Zend_Form_Element_Text( 'no_declarante_parentesco' );
		$noForm->setLabel( 'Parentesco:' )
				 ->setAttribs( array('size'=>'25','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
		         ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'30' ) ) )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( false );
		$this->addElement( $noForm );		
		
		$noForm 	= new Zend_Form_Element_Text( 'nu_declarante_telefone' );
		$noForm->setLabel( 'Telefone:' )
				 ->setAttribs( array('size'=>'25','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
		         ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'20' ) ) )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( false );
		$this->addElement( $noForm );		
		
		$noForm 	= new Zend_Form_Element_Text( 'nu_declarante_rg' );
		$noForm->setLabel( 'Identidade(RG):' )
				 ->setAttribs( array('size'=>'25','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
		         ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'15' ) ) )
		         ->setDecorators( $this->_decoratorLeft )
				 ->setRequired( false );
		$this->addElement( $noForm );

		$noForm 	= new Zend_Form_Element_Text( 'no_declarante_rg_emissor' );
		$noForm->setLabel( 'Órgão Emissor:' )
				 ->setAttribs( array('size'=>'25','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
		         ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'1', 'max'=>'15' ) ) )
		         ->setDecorators( $this->_decoratorLeft )
				 ->setRequired( false );
		$this->addElement( $noForm );		
		
		$obParamUfRepositorio = new App_Model_ParamUfRepository();
        $selectBox = new Zend_Form_Element_Select( 'sg_declarante_rg_uf_emissor' );
            $selectBox->setLabel('UF Emissor:');
            $selectBox->setAttribs( array('class'=> 'last-child' ) );
            $selectBox->setDecorators( $this->_decoratorLeft );
            $selectBox->addMultiOptions( Voitech_Util::converteModeloArrayCombo($obParamUfRepositorio->listarTodos(array('st_ativo'=>'S'))
                                            , 'SgUf', 'SgUf', true) );
            $selectBox->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $selectBox );		
		
		$this->addDisplayGroup(array( 'no_declarante','no_declarante_parentesco','nu_declarante_telefone','nu_declarante_rg','no_declarante_rg_emissor','sg_declarante_rg_uf_emissor'	)
									 ,'Cadastro4',array('legend' => 'Dados do Declarante', 'class'=>'grey-bg first-child last-child fieldset-with-legend fieldset-with-legend-first-child'));
		

		$obParamUfRepositorio = new App_Model_ParamUfRepository();
        $selectBox = new Zend_Form_Element_Select( 'sg_uf_sepultado' );
            $selectBox->setLabel('UF:');
            $selectBox->setAttribs( array('class'=> 'last-child' ) );
            $selectBox->setDecorators( $this->_decoratorLeft );
            $selectBox->addMultiOptions( Voitech_Util::converteModeloArrayCombo($obParamUfRepositorio->listarTodos(array('st_ativo'=>'S'))
                                            , 'SgUf', 'SgUf', true) );
            $selectBox->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $selectBox );

        $selectBox = new Zend_Form_Element_Select( 'co_cidade_sepultado' );
            $selectBox->setLabel('Cidade:');
            $selectBox->setAttribs( array('class'=> 'last-child' ) );
            $selectBox->setDecorators( $this->_decoratorDefault );
            $selectBox->addMultiOptions( array() );
            $selectBox->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $selectBox );									 
									 
		$noForm 	= new Zend_Form_Element_Text( 'dt_sepultamento' );
		$noForm->setLabel( 'Data do Sepultamento:' )
				 ->setAttribs( array('size'=>'15','class'=> 'first-child last-child campo_data') )
		         ->addFilter( new Zend_Filter_StringTrim() )
		         ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'1', 'max'=>'12' ) ) )
		         ->setDecorators( $this->_decoratorLeft )
				 ->setRequired( false );
		$this->addElement( $noForm ); 

		$noForm 	= new Zend_Form_Element_Text( 'nu_hora_sepultamento' );
		$noForm->setLabel( 'Hora do Sepultamento:' )
				 ->setAttribs( array('size'=>'10','class'=> 'first-child last-child ') )
		         ->addFilter( new Zend_Filter_StringTrim() )
		         ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'1', 'max'=>'5' ) ) )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( false );
		$this->addElement( $noForm ); 
				
		$this->addDisplayGroup(array( 'sg_uf_sepultado','co_cidade_sepultado','dt_sepultamento','nu_hora_sepultamento'	)
									 ,'Cadastro5',array('legend' => 'Dados do Sepultamento', 'class'=>'grey-bg first-child last-child fieldset-with-legend fieldset-with-legend-first-child'));
											 
	}
}